/**
 * 插入排序
 */

function insertSort(arr: number[]): number[] {
	const { length } = arr

	for (let i = 1; i < length; i++) {
		let j = i
		const tmp = arr[i]

		while (j > 0 && arr[j - 1] > tmp) {
			arr[j] = arr[j - 1]
			j--
		}

		arr[j] = tmp
	}

	return arr
}
